package cn.csc.module.shoppingCard.convert.card;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.module.shoppingCard.api.card.dto.CardMultiLockReqDTO;
import cn.csc.module.shoppingCard.api.card.dto.CardRespDTO;
import cn.csc.module.shoppingCard.controller.admin.card.vo.CardCreateReqVO;
import cn.csc.module.shoppingCard.controller.admin.card.vo.CardExcelVO;
import cn.csc.module.shoppingCard.controller.admin.card.vo.CardRespVO;
import cn.csc.module.shoppingCard.controller.admin.card.vo.CardUpdateReqVO;
import cn.csc.module.shoppingCard.dal.dataobject.card.CardDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 购物卡主表 Convert
 *
 * @author liuchuang
 */
@Mapper
public interface CardConvert {

    CardConvert INSTANCE = Mappers.getMapper(CardConvert.class);

    CardDO convert(CardCreateReqVO bean);

    CardDO convert(CardUpdateReqVO bean);

    CardRespVO convert(CardDO bean);

    List<CardRespVO> convertList(List<CardDO> list);

    List<CardRespDTO> convertList1(List<CardDO> list);

    @Mappings({
            @Mapping(source = "cardId", target = "id"),
            @Mapping(source = "orderId", target = "lockOrder")
    })
    CardDO dtoToDo(CardMultiLockReqDTO reqDTO);

    /**
     * 此时 dtoToDos 的实现为循环调用 dtoToDo 并继承了 dtoToDos 的属性映射
     */
    List<CardDO> dtoToDos(List<CardMultiLockReqDTO> list);

    PageResult<CardRespVO> convertPage(PageResult<CardDO> page);

    List<CardExcelVO> convertList02(List<CardDO> list);

}
